<html>

<body>
  <div>index</div>
</body>

<script>
  setInterval(() => {
     // 参数
    let urlPar = window.location.search
    if(!urlPar){
      let rand = createRandomId()
      sessionStorage.setItem("rand", rand)
      location.href = window.location.href + `?rand=${rand}`
    } else {

      if(sessionStorage.getItem("rand") === getQueryVariable('rand')){
        let rand = createRandomId()
        sessionStorage.setItem("rand", rand)
        location.href = updateQueryStringParameter(window.location.href, 'rand', rand)
      }
    }
  }, 5000);
 
  function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
      var pair = vars[i].split("=");
      if (pair[0] == variable) { return pair[1]; }
    }
    return (false);
  }

  function updateQueryStringParameter(uri, key, value) {
    var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
    var separator = uri.indexOf('?') !== -1 ? "&" : "?";
    if (uri.match(re)) {
        return uri.replace(re, '$1' + key + "=" + value + '$2');
    }
    else {
        return uri + separator + key + "=" + value;
    }
  }

  function createRandomId() {
    return (Math.random() * 10000000).toString(16).substr(0, 4) + '-' + (new Date()).getTime() + '-' + Math.random().toString().substr(2, 5)
  }
  

</script>
</html>


